package com.doctcloud.datacloud.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

import static com.doctcloud.common.core.utils.StringUtils.trim;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"itemClass","itemCode","itemSpec","units"})
@TableName("price_lastest")
public class PriceLastestEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "项目分类代码")
    @NotBlank(message = "项目分类代码不得为空")
    private String itemClass;
    @Excel(name = "项目代码")
    @NotBlank(message = "项目代码不得为空")
    private String itemCode;
    @Excel(name = "项目名称")
    @NotBlank(message = "项目名称不得为空")
    private String itemName;
    @Excel(name = "项目规格")
    @NotBlank(message = "项目规格不得为空")
    private String itemSpec;
    @Excel(name = "项目单位")
    @NotBlank(message = "项目单位不得为空")
    private String units;
    @Excel(name = "项目单价")
    @NotNull(message = "项目单价不得为空")
    private Double price;
    @Excel(name = "项目优惠价")
    @NotNull(message = "项目单价不得为空")
    private Double preferPrice;
    @Excel(name = "项目外宾价")
    @NotNull(message = "项目单价不得为空")
    private Double foreignerPrice;
    @Excel(name = "最后使用时间")
    @NotNull(message = "最后时间不得为空")
    private Date updateDate;
    @Data
    public static class Key {
        private final String itemClass;
        private final String itemCode;
        private final String itemSpec;
        private final String units;

        public Key(String itemClass, String itemCode, String itemSpec, String units) {
            this.itemClass = itemClass;
            this.itemCode = itemCode;
            this.itemSpec = itemSpec;
            this.units = units;
        }
        // Lombok 的 @Data 会自动生成所有字段的构造函数、getter、setter、toString、equals 和 hashCode
        // 对于 final 字段，@Data 会生成一个包含所有 final 字段的构造函数
    }

    public void setItemClass(String itemClass) {
        this.itemClass = trim(itemClass);
    }

    public void setItemCode(String itemCode) {
        this.itemCode = trim(itemCode);
    }

    public void setItemName(String itemName) {
        this.itemName = trim(itemName);
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setUnits(String units) {
        this.units = trim(units);
    }
}
